<?php

include "../controller/ConectBanco.php";

class ModelDAO{
	
	function insert(Model $model){
	
		mysql_query("INSERT INTO model SET modelo = '".$model->getModelo()."'
							, padrao = '". $model->getPadrao()."'
							, brand = '". $model->getMarca()."'		
							, aplicacao = '". $model->getAplicacao()."'
							, waterproof = '". $model->getWaterproof()."'
							, escuta = '". $model->getEscuta()."'
							, cortaCombust = '". $model->getCortaCombust()."'
							, cortaEletric = '". $model->getCortaEletric()."'
							, sos = '". $model->getSos()."'
							, bateria = '". $model->getBateria()."'
							, sdCard = '". $model->getSdCard()."'
							, vibracao = '". $model->getVibracao()."'
							, ft_alarm = '". $model->getFt_alarm()."'
							, ft_tracking = '". $model->getFt_tracking()."'
							, ft_charge= '". $model->getFt_charge()."'
							, ft_acc = '". $model->getFt_acc."'
							, ft_voltage = '". $model->getFt_voltage()."'
							, ft_gsmsignal = '". $model->getFt_gsmsignal()."'")	or die (mysql_error());
	
		header("location:../view/ListaModels.php");
	
	}
	
	function delete($idModel){
		mysql_query("DELETE FROM model WHERE idModel =".$idModel) or die (mysql_error());
	
		header("location:../view/ListaModels.php");
	}
	
	function update(Model $model){
		mysql_query("UPDATE model SET modelo = '".$model->getModelo()."'
									, padrao = '". $model->getPadrao()."'
									, brand = '". $model->getMarca()."'
									, aplicacao = '". $model->getAplicacao()."'
									, waterproof = '". $model->getWaterproof()."'
									, escuta = '". $model->getEscuta()."'
									, cortaCombust = '". $model->getCortaCombust()."'
									, cortaEletric = '". $model->getCortaEletric()."'
									, sos = '". $model->getSos()."'
									, bateria = '". $model->getBateria()."'
									, sdCard = '". $model->getSdCard()."'
									, vibracao = '". $model->getVibracao()."' 
									, ft_alarm = '". $model->getFt_alarm()."' 
									, ft_tracking = '". $model->getFt_tracking()."' 
									, ft_charge = '". $model->getFt_charge()."' 
									, ft_acc = '". $model->getFt_acc()."'
									, ft_voltage = '". $model->getFt_voltage()."'
									, ft_gsmsignal = '". $model->getFt_gsmsignal()."' WHERE idModel='".$model->getIdModel()."'") or die (mysql_error());
	
		header("location:../view/ListaModels.php");
	}
	
	
}
?>